using System.Collections.Generic;

namespace IQIGame.Onigao.GamePlay
{
    public class DynParamProcessTriggerRect : DynParamProcessBase
    {
        public DynParamProcessTriggerRect(LevelPlayRegionController regionCtrl) : base(regionCtrl)
        {
        }

        public override EntityDynamicParamType paramType => EntityDynamicParamType.TriggerRect;

        public override void OnListParamEffectiveChanged(EntityDynamicParamType paramType, IReadOnlyList<BaseEntityDynamicParam> paramValueList, IReadOnlyList<LevelPlayBaseEntity> entityList)
        {
            bool hasPhysical = false;
            for (int i = 0; i < paramValueList.Count; i++)
            {
                var p = paramValueList[i] as EntityParamTriggerRect;
                if (p.isPhysicNavTrigger)
                {
                    hasPhysical = true;
                    break;
                }
            }
            var mainCharacter = LevelPlayUtil.GetMainCharacter();
            mainCharacter?.GetMoveComponent()?.SwtichPhysicalMovement(hasPhysical);
        }
    }
}
